package main

import "fmt"

func main() {
	array := [...]string{"a", "b", "c", "d", "e"}
	//fmt.Println(array[2])
	for i := 0; i < 5; i++ {
		//fmt.Println("数组索引:%d对应值:%s\n", i, array[i])
	}
	for i, v := range array {

		fmt.Printf("数组索引:%d,对应值:%s\n", i, v)

	}

	for _, v := range array {
		fmt.Println("对应值：", v)
	}

	slice := array[2:5]
	slice[1] = "f"
	fmt.Println(array)
	//slice1 := make([]string, 4)
	slice1 := make([]string, 4, 8)
	fmt.Println(slice1)
	slice2 := []string{"a", "b", "c", "d", "e"}
	fmt.Println(len(slice2), cap(slice2))

	nameAgeMap := make(map[string]int)
	nameAgeMap["飞雪无情"] = 20
	nameAgeMap = map[string]int{"飞雪五星": 20}
	nameAgeMap = map[string]int{"飞雪五星1": 20}
	//添加键值对或者更新对应的key的value
	nameAgeMap["飞雪无情"] = 20
	//获取指定key对应的value
	age := nameAgeMap["飞雪无情"]
	fmt.Println(age)
	age, ok := nameAgeMap["飞雪无情"]
	if ok {
		fmt.Println(age)
	}
	delete(nameAgeMap, "飞雪无情")
	fmt.Println(nameAgeMap)
	for k, v := range nameAgeMap {
		fmt.Println("key is", k, ",value is", v)
	}
	fmt.Println(len(nameAgeMap))
	s := "Hello飞雪无情"
	bs := []byte(s)
	fmt.Println(bs)
	fmt.Println(s[0], s[1], s[15])
}
